package com.hospital.pharmacy.impl;

import com.alibaba.fastjson.JSON;
import com.hospital.login.entity.AdminUser;
import com.hospital.pharmacy.dao.MedicineMapper;
import com.hospital.pharmacy.entity.Medicine;
import com.hospital.pharmacy.service.MedicineService;
import com.hospital.pharmacy.service.PharmacyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class MedicineServiceImpl implements MedicineService{
    @Autowired
    MedicineMapper medicineMapper;

    /**
    * @Description: 插入药品
    * @Param: [medicine]
    * @return: void
    * @Author: 杨mz
    * @Date: 2018/12/4
    */ 
    @Override
    public void insertMed(String num,
                          String name,
                          String unit,
                          String spec,
                          Integer type,
                          Integer supplier,
                          String company,
                          String remark){
        Medicine medicine = new Medicine();
        medicine.setMdcCompany(company);
        medicine.setMdcName(name);
        medicine.setMdcNum(num);
        medicine.setMdcRemark(remark);
        medicine.setMdcSpec(spec);
        medicine.setMdcSupplierId(supplier);
        medicine.setMdcUnit(unit);
        medicine.setMdcTypeId(type);
        medicineMapper.insert(medicine);
    }
@Override
    public void deleteMed(Integer id){

        medicineMapper.deleteByPrimaryKey(id);
}
/*@Override
    public String getAll(){
    Medicine medicine=new Medicine();
    return JSON.toJSONString(medicineMapper)
}*/
   /* @Override
    public String getAll() {
        AdminUserExample example = new AdminUserExample();
//        return JSON.toJSONString(adminUserMapper.selectByExample(example));
        List<AdminUser> adminUsers = adminUserMapper.selectByExample(example);
        //userNum
        //userName
        List<Map<String,String>> resultMap = new ArrayList<>();
        Map<String,String> map;
        for (AdminUser user : adminUsers) {
            map = new HashMap<>();
            map.put("userNum",user.getAdNum());
            map.put("userName",user.getAdName());
            resultMap.add(map);
        }
        return JSON.toJSONString(resultMap);
    }*/




}
